<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <p>点击按钮，测试带有 break 语句的循环。</p>
        <button onclick="myFunction()">点击这里</button>
        <p id="demo"></p>
        <script>
            function myFunction() {
                var x = "", i = 0;
                for (i = 0; i < 2; i++) {
                    if (i == 20) {
                        break;
                    }
                    x = x + "该数字为 " + i + "<br>";
                }
                document.getElementById("demo").innerHTML = x;
            }
        </script>
        <!-- Break 语句 -->
    </div>
    <hr />
    <div>
        <p>点击下面的按钮来执行循环，该循环会跳过 i=3 的步进。</p>
        <button onclick="myFuanction()">点击这里</button>
        <p id="demoadad"></p>
        <script>
            function myFuanction() {
                var x = "", i = 0;
                for (i = 0; i < 10; i++) {
                    if (i == 4) {
                        continue;
                    }
                    x = x + "该数字为 " + i + "<br>";
                }
                document.getElementById("demoadad").innerHTML = x;
            }
        </script>
        <!-- Continue 语句 -->
    </div>
    <hr />
    <div>
        <script>
            cars = ["BMW", "Volvo", "Saab", "Ford"];
            list: {
                document.write(cars[0] + "<br>");
                break list;
                document.write(cars[1] + "<br>");
                document.write(cars[2] + "<br>");
                break list;
                // break list;
                document.write(cars[3] + "<br>");
                document.write(cars[4] + "<br>");
                break list;
                document.write(cars[5] + "<br>");
            }
        </script>
    </div>
</body>

</html>